package com.pactera.mavenweb.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.pactera.mavenweb.dao.RoleDao;
import com.pactera.mavenweb.entity.Role;
import com.pactera.mavenweb.service.RoleService;

@Service("roleService")
public class RoleServiceImpl implements RoleService {
	
	/**
	 * 注入dao
	 */
	@Resource(name = "roleDao")
	private RoleDao roleDao;
	
//	@Override
	public int saveRoles(List<Role> roles) {
		try {
			for (Role role : roles) {
				roleDao.saveRole(role);
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return 0;
	}
	
//	@Override
	public List<Role> getAllRole() {
		return roleDao.queryAll();
	}
	
//	@Override
	public void addRole(Role role) {
		roleDao.saveRole(role);
	}
	
//	@Override
	public boolean delRole(String id) {
		
		roleDao.delete(id);
		
		return true;
	}
	
//	@Override
	public void updateRole(Role role) {
		roleDao.update(role);
	}
	
//	@Override
	public Role getRole(int id) {
		return roleDao.queryById(id);
	}
}